#!/usr/bin/env python
# encoding: utf-8
'''
@author: Excelsiorly
@license: (C) Copyright 2021, All Rights Reserved.
@contact: excelsiorly@qq.com
@file: 0037.py
@time: 2021/12/2 12:52
@desc:
'''


class Solution(object):
    def findRelativeRanks(self, score: list):
        """
        :type score: List[int]
        :rtype: List[str]
        """
        # 记录每个分数对应的编号
        n = len(score)
        dic = {}
        for i in range(n):
            dic[score[i]] = i

        # 排序
        score.sort(reverse=True)

        # 创建answer
        answer = [' ' for i in range(n)]
        for i in range(n):
            idx = dic[score[i]]  # 找到队员编码
            if i == 0:
                answer[idx] = 'Gold Medal'
            elif i == 1:
                answer[idx] = 'Silver Medal'
            elif i == 2:
                answer[idx] = 'Bronze Medal'
            else:
                answer[idx] = str(i + 1)

        return answer

if __name__ == '__main__':
    inp = [5,4,3,2,1]
    res = Solution().findRelativeRanks(inp)
    print(res)